/*
 * @Descripttion:
 * @version:
 * @Author: JinYiGao
 * @Date: 2021-08-29 16:12:25
 * @LastEditors: JinYiGao
 * @LastEditTime: 2021-08-29 16:12:26
 */
#pragma once

#include <glad/glad.h>
#include <stb_image.h>

#include <utils/mesh.h>
#include <utils/shader.h>

#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>

#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

class Model {
public:
    Model();
    ~Model();

    Model(string const &path, bool gamma = false);

public:
    // model Data
    vector<Texture> textures_loaded; // 缓存已加载纹理
    vector<Mesh> meshes;
    string directory;     // 模型路径
    bool gammaCorrection; // gamma校正

    void Draw(Shader *shader);

private:
    void loadModel(string const &path);
    void processNode(aiNode *node, const aiScene *scene);
    Mesh processMesh(aiMesh *mesh, const aiScene *scene);
    vector<Texture> loadMaterialTextures(aiMaterial *mat, aiTextureType type, string typeName);
};
